<?php
    session_start();
    
    if(isset($_POST['val'])) {
        $_SESSION['user_name'] = $_POST['val']['username'];
    }
    
    if(isset($_SESSION['user_name'])) {
        echo $_SESSION['user_name'];
    }
?>

<form method="POST">
    <input type="text" name="val[username]" />
    <input type="password" name="val[password]" />
    <input type="submit" name="Login" />
</form>